package com.echo.yixiaowu.feature.player

import androidx.compose.runtime.Immutable
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.echo.yixiaowu.data.model.player.CardDetailItemData
import com.echo.yixiaowu.data.model.player.CommentData
import com.echo.yixiaowu.feature.main.home.HomeTabItem

// 媒体或文本
@Immutable
data class CardDetailUiState(
    val fetchDataState: FetchBackendDataUiState = FetchBackendDataUiState(),
    val itemData: CardDetailItemData? = null,
)

// 评论
@Immutable
data class CommentUiState(
    val fetchDataState: FetchBackendDataUiState = FetchBackendDataUiState(),
    val commentList: List<CommentData> = emptyList(),
)

// 请求状态
@Immutable
data class FetchBackendDataUiState(
    val isLoading: Boolean = true,
    val error: String? = null,
    val lastFetchedTimestamp: Long = 0L
)

// 媒体界面状态
@Immutable
data class MediaUIState(
    val width: Int = 1920,
    val height: Int = 1080,
    val screenWidth: Int = 1920,
    val screenHeight: Int = 1080,
    val videoHeight: Dp = 230.dp,
    val originalVideoHeight: Dp = videoHeight,
    val minimumHeight: Dp = 230.dp,
    val totalDuration: Long = 0L,
    val currentDuration: Long = 0L,
    val progress: Float = 0f,
    val bufferProgress: Float = 0f,
    val isExpanded: Boolean = false,
    val isPlaying: Boolean = true,
    val isLiked: Boolean = false,
    val isDisliked: Boolean = false,
    val isFavorite: Boolean = false,
    val isFullScreen: Boolean = false,
    val isShowControl: Boolean = false,
)

val videoPageItem = listOf(
    HomeTabItem(1,"简介"),
    HomeTabItem(2,"评论"),
)

/**
 * 可以触发的事件
 */
sealed class MediaPageIntent {
    data class LoadItemData(val itemId: String) : MediaPageIntent()
    data class LoadCommentData(val itemId: String) : MediaPageIntent()
    data class ClickCommentLike(val commentId: String) : MediaPageIntent()
    data class ClickCommentDislike(val commentId: String) : MediaPageIntent()
    data class ClickMediaFavorite(val isFavorite: Boolean) : MediaPageIntent()
    data class ClickMediaFullScreen(val isFullScreen: Boolean, val newHeight: Dp) :
        MediaPageIntent()

    data class ClickMediaExpand(val isExpanded: Boolean) : MediaPageIntent()
    data class ClickMediaLike(val isLike: Boolean) : MediaPageIntent()
    data class ClickMediaDislike(val isDislike: Boolean) : MediaPageIntent()
    data class ClickShowControls(val isShow: Boolean) : MediaPageIntent()
    data class ClickPlaying(val isPlaying: Boolean) : MediaPageIntent()
    data class SetControlVisible(val isVisible: Boolean) : MediaPageIntent()
    data class SeekToProgress(val progress: Float) : MediaPageIntent()
}